/**
 * @param {number[]} capacity
 * @param {number[]} rocks
 * @param {number} additionalRocks
 * @return {number}
 */
var maximumBags = function (capacity, rocks, additionalRocks) {
    const fill = []
    let count = 0
    for (let i = 0; i < capacity.length; i++) {
        fill[i] = capacity[i] - rocks[i]
    }
    fill.sort((a, b) => {
        return a - b
    })
    for (let i = 0; i < fill.length; i++) {
        if (fill[i] !== 0 && additionalRocks >= fill[i]) {
            additionalRocks -= fill[i]
            fill[i] = 0
        }
        if (fill[i] === 0) {
            count++
        }
    }
    return count
};